package com.xuzhen.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionSupport;
import com.xuzhen.domain.User;
import com.xuzhen.service.UserService;

@Component("testController")
@Scope("request")
public class TestController extends ActionSupport {
	private static final long serialVersionUID = 1L;

	private String userName;
	private User user;

	@Autowired
	private UserService userService;

	public String hello() {
		userName = "nihao";
		return Action.SUCCESS;
	}

	public String helloJson() {
		user = userService.findByUserName("xuzhen");
		if (user == null) {
			user = new User();
			user.setRemark("aaa");
			user.setPassword("aaa");
			user.setUserName("aaa");
		}
		return Action.SUCCESS;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

}
